var t = require("../../@babel/runtime/helpers/interopRequireDefault")(require("../../dist/dialog/dialog")), a = getApp();

Page({
    data: {
        available_point: 0,
        info: {},
        count: 0,
        value: 0,
        mobile: "",
        point: ""
    },
    onChange: function(t) {
        var a = t.detail;
        if (this.setData({
            value: a
        }), 0 !== this.data.info.out_rate && 0 !== this.data.info.in_rate) {
            var n = this.data.value * this.data.info.in_rate;
            return (n = n.toString()).length > 5 && (n = (n = Number(n)).toFixed(2)), void this.setData({
                count: n
            });
        }
        this.setData({
            count: 0
        });
    },
    focus_input: function(t) {
        0 == t.detail.value && this.setData({
            value: ""
        });
    },
    get_exchange: function() {
        var t = this;
        a._getNetWork({
            url: a.getNetAddresss("plugin.point-exchange.frontend.exchange.index"),
            success: function(n) {
                var e = n.data, i = e.result, o = e.msg, s = e.data;
                if (0 == i) return a.tips(o);
                if (s.member_mobile) {
                    var c = wx.getStorageSync("point_phone");
                    c ? t.setData({
                        mobile: c
                    }) : t.setData({
                        mobile: s.member_mobile
                    });
                }
                t.setData({
                    info: s
                }), wx.setNavigationBarTitle({
                    title: "".concat(s.name)
                });
            }
        });
    },
    handleAll: function() {
        this.setData({
            value: this.data.info.member_point
        });
    },
    submit: function() {
        var a = this;
        t.default.confirm({
            message: "\n      ".concat(this.data.value, "个").concat(this.data.point, "将转兑到").concat(this.data.info.another_name.shop, "的").concat(this.data.info.another_name.point, "\n      到账数量：").concat(this.data.count).concat(this.data.info.another_name.point, "\n        手机号：").concat(this.data.mobile)
        }).then(function() {
            a.confirm();
        }).catch(function() {});
    },
    mobile_handle: function(t) {
        this.setData({
            mobile: t.detail.value
        });
    },
    confirm: function() {
        var t = this, n = {
            point: this.data.value,
            mobile: this.data.mobile
        };
        a._getNetWork({
            url: a.getNetAddresss("plugin.point-exchange.frontend.exchange.exchange"),
            data: n,
            success: function(n) {
                var e = n.data, i = e.result, o = e.msg, s = e.data;
                if (0 == i) return a.tips(o);
                t.setData({
                    value: 0
                }), wx.setStorageSync("point_phone", t.data.mobile), a.tips(o), s.mini_url && wx.navigateToMiniProgram({
                    appId: s.mini_app_id,
                    path: s.mini_url
                });
            }
        });
    },
    onLoad: function(t) {
        var a = wx.getStorageSync("integral");
        this.setData({
            point: a
        }), this.get_exchange();
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {}
});